package com.server.controller;

import com.server.domain.Code;
import com.server.domain.Response;
import com.server.entity.WaterSe;
import com.server.service.WaterSeService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;


/**
 * 硒含量(WaterSe)表控制层
 *
 * @author wzw
 * @since 2024-07-31 19:54:13
 */
@RestController
@RequestMapping("waterSe")
public class WaterSeController {
    @Resource
    WaterSeService waterSeService;
    
    // 按时间查询
    @GetMapping("/selectByTime")
    public Response WaterSeByTime(@RequestParam String startTime,@RequestParam String endTime) {
        System.out.println("查询时间"+startTime+"-"+endTime+"的数据");
         // time=2024-07-06 15:15:15
         List<WaterSe> data = waterSeService.findWaterSe(startTime,endTime);
         if(data != null){
             return new Response("获取硒含量明细报表成功！",data, Code.RESONSE_OK);
         }else{
            return new Response("获取硒含量明细报表失败！请输入正确的日期",null, Code.BUSINESS_PARAM_ERR);
            }
     }
    // 获取最新数据
    @GetMapping("/latest")
    public Response selectLatest() {
        List<WaterSe> data = waterSeService.selectLatest();
        if(data != null){
            return new Response("获取实时硒含量报表成功！",data, Code.RESONSE_OK);
        }else{
            return new Response("获取实时硒含量报表失败！请输入正确的日期",null, Code.BUSINESS_PARAM_ERR);
        }
    }
}
